package HTTPReciveParser;

public class ForwardConf {
	private String forwardConfMessage;
	
	public static final String MMS_MESSAGE_TYPE = "X-Mms-Message-Type: ";
	public static final String MMS_TRANSACTION_ID = "X-Mms-Transaction-ID: ";
	public static final String MMS_VERSION = "X-Mms-MMS-Version: "; 
	public static final String MMS_RESPONSE_STATUS = "X-Mms-Response-Status: ";
	public static final String MMS_MESSAGE_ID = "Message-ID: ";
	public static final String MMS_CONTENT_LOCATION_VALUE = "X-Mms-Content-Location: "; 
	public static final String MMS_STORE_STATUS_VALUE = "X-Mms-Store-Status: ";
	
	private String mmsMessageType;
	private String mmsTransactionId;
	private String mmsVersion;
	private String mmsResponseStatus;
	private String mmsMessageID;
	private String mmsContentLocationValue;
	private String mmsStoreStatusValue;

	public String getMessageType(){
		return mmsMessageType;
	}
	
	public String getTransactionId(){
		return mmsTransactionId;
	}
	
	public String getVersion(){
		return mmsVersion;
	}
	
	public String geMessageID(){
		return mmsMessageID;
	}
	
	public String getResponseStatus(){
		return mmsResponseStatus;
	}
	
	public String getContentLocationValue(){
		return mmsContentLocationValue;
	}

	public String getStoreStatusValue(){
		return mmsStoreStatusValue;
	}
	
	public ForwardConf(String forwardConfMessage){
		this.forwardConfMessage = forwardConfMessage;
	}
	
	public void parseMessage(){
		
		try{
			String[] result = forwardConfMessage.split("\n");
			
			int i=0;			
			for(i=0 ; i<result.length ; i++)
			{
				if(result[i].startsWith(MMS_MESSAGE_TYPE))
					mmsMessageType=(result[i].substring((result[i].indexOf(':'))+1));
				
				else if(result[i].startsWith(MMS_TRANSACTION_ID))
					mmsTransactionId=result[i].substring((result[i].indexOf(':'))+1); 
				
				else if(result[i].startsWith(MMS_VERSION))
					mmsVersion=result[i].substring((result[i].indexOf(':'))+1);
				
				else if(result[i].startsWith(MMS_RESPONSE_STATUS))
					mmsResponseStatus=result[i].substring((result[i].indexOf(':'))+1);
				
				else if(result[i].startsWith(MMS_MESSAGE_ID))
					mmsMessageID=result[i].substring((result[i].indexOf(':'))+1);
			}
			
		}catch (ArrayIndexOutOfBoundsException e){
			System.out.println("Malformed response message");
		}
	}
	
}
